<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>无标题文档</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" />
  <script src="${pageContext.request.contextPath}/layui/jquery2.1.1.js"></script>
  <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>采购单管理</li>
    <li>采购单详情</li>
  </ul>
</div>
<form action="">
<div class="formbody">
  <div class="formtitle"><span>采购单信息</span></div>
  <div class="layui-form-item">
    <label class="layui-form-label">采购单编号</label>
    <div class="layui-input-inline" >
      <input id="number" name="number" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">采购时间</label>
    <div class="layui-input-inline" >
      <input id="poTime" name="poTime" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">总金额</label>
    <div class="layui-input-inline" >
      <input id="amount" name="amount" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">操作人</label>
    <div class="layui-input-inline" >
      <input id="userPerson" name="userPerson" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">审核状态</label>
    <div class="layui-input-inline" >
      <input id="a_status" type="text" value="" readonly="readonly" class="layui-input" />
      <input id="status" name="status" type="hidden" value="" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">审核意见</label>
    <div class="layui-input-inline" >
      <input id="content" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">审核人</label>
    <div class="layui-input-inline" >
      <input id="auditor" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">审核时间</label>
    <div class="layui-input-inline" >
      <input id="auditTime" type="text" value="" readonly="readonly" class="layui-input" />
    </div>
  </div>
  <table id="PurchaseTable" lay-filter="PurchaseTable"></table>
</div>
</form>
<script type="text/javascript">
  layui.use(['table', 'form'], function () {
    var table = layui.table,
            $ = layui.jquery,
            util = layui.util,
            form = layui.form;
    $(function () {
      //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
      var parent_json = eval('('+parent.json+')');
      $("#number").val(parent_json.number);
      $.ajax({
        url: "/PurchaseOrder/findPurchaseOrderByNumber?number="+$("#number").val(),
        type: 'post',
        dataType: 'json',
        success: function (res) {
          var data = res;
          $("#amount").val("￥"+data.amount);
          $("#userPerson").val(data.userPerson);
          $("#status").val(data.status);
          if ($("#status").val()=="1"){
            $("#a_status").val("未审核");
          }else if($("#status").val()=="2"){
            $("#a_status").val("审核中");
          }else if($("#status").val()=="3"){
            $("#a_status").val("审核通过");
          }else{
            $("#a_status").val("审核未通过");
          }
          $("#poTime").val(util.toDateString(data.poTime, "yyyy-MM-dd HH:mm:ss"));
        },
        error: function () {
          layer.msg('系统错误，请联系管理员', {icon: 5});
        }
      });
      form.render();
    });
    //展示已知数据
    table.render({
      elem: '#PurchaseTable'
      , url: 'http://localhost:8080/PurchaseOrderDetails/getPurchaseOrderDetailsList?number='+$("#number").val() //数据接口
      , cols: [[ //表头
        {field: 'orderId', title: '序号', width: 105, align: "center"}
        , {field: 'name', title: '品牌', width: 105,align: "center"}
        , {field: 'type', title: '类型', width: 105, align: "center"}
        , {field: 'mode', title: '型号', width: 105, align: "center"}
        , {field: 'manufacturer', title: '厂商', width: 105, align: "center"}
        , {field: 'num', title: '数量', width: 105, align: "center"}
        , {field: 'units', title: '单位', width: 105, align: "center"}
        , {field: 'price', title: '单价', width: 105, align: "center"}
        , {field: 'amounts', title: '金额', width: 113, align: "center"}
      ]]
    });
    form.render();
  });
</script>
</body>
</html>
